//
//  YWUIAlertView.m
//  YWBaseFrameWork
//
//  Created by mac on 16/7/17.
//  Copyright © 2016年 NeiQuan. All rights reserved.
//

#import "YWUIAlertView.h"
#include <objc/runtime.h>
@interface YWUIAlertView ()<UIAlertViewDelegate>
{
 
    
}
@end
static const void *YWAlertKey = &YWAlertKey;

@implementation YWUIAlertView
- (instancetype)initWithTitle:( NSString *)title message:( NSString *)message  cancelButtonTitle:( NSString *)cancelButtonTitle otherButtonTitles:( NSString *)otherButtonTitles buttonclickIndex:(YWalertBlock)buttonindex

{
    if (self=[super initWithTitle:title message:message delegate:self cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil])
    {
        
        if (buttonindex)
        {
            objc_setAssociatedObject(self, YWAlertKey, buttonindex, OBJC_ASSOCIATION_COPY);
        }
        
        
    }
    return self;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
   YWalertBlock  buttonindex = objc_getAssociatedObject(self,YWAlertKey);
   buttonindex(buttonIndex);
    
    
}
@end
